package com.yaorange.common.enums;

public enum YesOrNoEnum {

    YES("是", 1),

    NO("否", 0);

    public final String NAME;
    public final int CODE;

    YesOrNoEnum(String name, int code) {
        this.NAME = name;
        this.CODE = code;
    }

    /**
     * 匹配枚举值
     *
     * @param name 名称
     * @return YesOrNoEnum
     */
    public static YesOrNoEnum of(String name) {
        if (name == null) {
            return null;
        }
        YesOrNoEnum[] values = YesOrNoEnum.values();
        for (YesOrNoEnum yesOrNoEnum : values) {
            if (yesOrNoEnum.NAME.equals(name)) {
                return yesOrNoEnum;
            }
        }
        return null;
    }
}
